<?php


namespace app\common\model\xiluedu;


use app\common\library\Auth;
use think\Model;
use function fast\array_get;

class UserVip extends Model
{
    // 表名
    protected $name = 'xiluedu_user_vip';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'expire_time_text'
    ];


    public function getExpireTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['expire_time']) ? $data['expire_time'] : '');
        return is_numeric($value) ? date("Y-m-d", $value) : $value;
    }
    public static function isVip($user_id)
    {
        return static::where('user_id', $user_id)->where('expire_time', 'egt', strtotime(date('Y-m-d')))->find() ? 1 : 0;
    }
 
}
